import { memo, forwardRef,useImperativeHandle } from 'react'
const Child = forwardRef((props: any, ref: any) => {
    const { title, name,changeTitle,changeName } = props
    const handleTitle = () => {
        changeTitle && changeTitle()
    }
    const handleName = () => {
        changeName && changeName()
    }
    useImperativeHandle((ref)=>({
        handleName
    }))
    return (
        <>
            <div>
                标题：{{ title }}
                姓名：{{ name }}
                <button onClick={handleTitle}>修改标题</button>
                <button onClick={handleName}>修改姓名</button>
            </div>
        </>
    )
})
export default memo(Child,(pre,next)=>pre.num === next.num)